home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / com_pkg3.zip / COM_PKG3.ASM next >
Assembly Source File  |  1986-06-01  |  42KB  |  1,056 lines

  1. 30-May-86 01:03:08-PDT,41855;000000000001
  2. Return-Path: <milne@ICSE.UCI.EDU>
  3. Received: FROM ICSE.UCI.EDU BY USC-ISIB.ARPA WITH TCP ; 30 May 86 00:57:05 PDT
  4. Received: from localhost by ICSE.UCI.EDU id a007132; 29 May 86 22:54 PDT
  5. To: info-ibmpc@usc-isib.arpa
  6. Subject: ComPackage version for UCSD p-System
  7. Date: Thu, 29 May 86 22:54:20 -0800
  8. From: Alastair Milne <milne@ICSE.UCI.EDU>
  9.  
  10.  
  11.  
  12.    Here is my adaptation of the simpler version of ComPackage for the UCSD
  13.    p-System.  There are 5 or 6 separate source files, mostly because of
  14.    limitations of the p-System assembler.  They are delimited by <<<<< marks.
  15.  
  16.    I have placed on each file the documentation header we use at work, to
  17.    explain it and give its relations to the other files.  I hope they will be
  18.    adequate: this is the first time I've sent them to a non-p-System
  19.    installation.
  20.  
  21.    Several of the names exported to Pascal have been changed (lengthened).  
  22.    This was done to make them clearer, and in particular to avoid confusion 
  23.    with names from other units trying to serve the same purpose.  I trust 
  24.    it will not result in too much confusion.
  25.  
  26.    The bug fix I reported is in the interrupt service routine, whose file is
  27.    still called COM.PKG1.TEXT.
  28.  
  29.    I hope you will not find restoring this to MASM conventions overly
  30.    difficult.  If questions arise about what I've done, I'll be happy to help.
  31.  
  32.  
  33.    Thank you,
  34.    Alastair Milne
  35.    
  36. <<<<<<<<<<<<<<<<<<<<<<<<<<<
  37. ;{% global equates and macro definitions for ComPackage
  38. ;File Name : COM.EQU.TEXT  Code Name : <none>
  39. ;
  40. ;Assembly context.  
  41. ;  Files included :  none
  42. ;
  43. ;%}
  44. rsize   .equ     2048            ; size of receive buffer
  45. tsize   .equ     256             ; size of transmit buffer
  46. base    .equ     3F0H            ; base of address of aux. port registers
  47. aux_int .equ     0CH             ; interrupt number for aux port
  48. int_off .equ     aux_int*4       ; offset of interrupt vector
  49. datreg  .equ     base + 8H       ; data register
  50. dll     .equ     base + 8H       ; low divisor latcH
  51. dlh     .equ     base + 9H       ; high divisor latch
  52. ier     .equ     base + 9H       ; interrupt enable register
  53. iir     .equ     base + 0AH      ; interrupt identification register
  54. lcr     .equ     base + 0BH      ; line control register
  55. mcr     .equ     base + 0CH      ; modem control register
  56. lsr     .equ     base + 0DH      ; line status register
  57. msr     .equ     base + 0EH      ; modem status register
  58. dla     .equ     80H             ; divisor latch access
  59. mode    .equ     03H             ; 8-bits, no parity
  60. dtr     .equ     0BH             ; bits to set dtr line
  61. dtr_of  .equ     00H             ; turn off dtr, rts, and tHe interupt driver
  62. thre    .equ     20H             ; mask to find status of xmit holding register
  63. rxint   .equ     01H             ; enable data available interrupt
  64. txint   .equ     02H             ; enable tx holding register empty interrupt
  65. tcheck  .equ     20H             ; mask for checking tx reg status on interrupt
  66. rcheck  .equ     01H             ; mask for checking rx reg status on interrupt
  67. imr     .equ     21H             ; interuprt mask register
  68. int_mask .equ    0EFH            ; mask to clear bit 4
  69. int_pend .equ    01H             ; there is an interrupt pending
  70. mstat   .equ     00H             ; modem status interrupt
  71. wr      .equ     02H             ; ready to xmit data
  72. rd      .equ     04H             ; received data interrupt
  73. lstat   .equ     06H             ; line status interrupt
  74. ack     .equ     244             ; acknowledge symbol
  75. parity  .equ     7FH             ; bits to mask off parity
  76. ocw2    .equ     20H             ; operational control word on 8259
  77. eoi     .equ     64H             ; specific end of interrupt 4
  78. brkbit  .equ     40H             ; bits to cause break
  79. true    .equ     1               ; truth
  80. false   .equ     0               ; falsehood
  81. XOn     .equ     17              ; ASCII Transmit On code, for XOn/XOff protocl
  82. XOff    .equ     19              ; ASCII Transmit Off code,  "    "        "
  83.         
  84. ; assumes the parameter is the first word of an IP:CS pair, 
  85. ;    places the current CS into the CS half, and does an 
  86. ;    indirect long call to the routine pointed to.
  87. ;    NOTE: destroys bx
  88. .macro  CallRel
  89.         lea     bx, cs:%1
  90.         mov     cs:(bx+2), cs
  91.         calll   cs:(%1)
  92. .endm
  93.  
  94. <<<<<<<<<<<<<<<<<<<<<<<<<<<
  95.         .title   "COM.PKG"
  96. ;{% interrupt handler, installer, and remover for ComPackage
  97. ;File Name : COM.PKG1.TEXT   Code Name :  COM.PKG1.CODE
  98. ;
  99. ;History:
  100. ; (Adapted from code for MS-Pascal by John Romkey and Jerry Saltzer of MIT
  101. ;  by Richard Gillmann (GILLMANN@ISIB), 1983.  Taken from COM_PKG1.ASM
  102. ;  from the INFO-IBMPC repository at the University of Southern California.)
  103. ;Date           Coder           Modification
  104. ; winter, 1986  Alastair Milne    Adapted to p-System assembler syntax,
  105. ;                                 and p-System calling conventions.
  106. ;                                 - clearing of serial port (i.e. forced break)
  107. ;                                   moved from init. of interrupt handler
  108. ;                                   to user-callable routine.
  109. ;                                 - XOn/XOff protocol (input & output) added to
  110. ;                                   intrpt handler.
  111. ;                                 - bug fix: transmit-ready interrupt is raised
  112. ;                                      before transmit shift register is ready.
  113. ;                                      Caused strings to be sent as garbage.
  114. ;                                      Added loop to wait for the shift reg.
  115. ;                                         before sending.
  116. ;
  117. ;Assembly context.  
  118. ;  Files included :  COM.EQU.TEXT
  119. ;
  120. ;Linked to : COM.PKG.P.CODE    to obtain : COM.PKG.CODE
  121. ;
  122. ;Important Additional Info: 
  123. ;    All this code expects to use serial port 1 on the IBM PC or compatibles.
  124. ;       No allowance is made for machines with no serial port installed.
  125. ;
  126. ;%}
  127. ;
  128.  
  129. .include        com.equ.text
  130.  
  131. ;
  132. ; int_hndlr - handles interrupts generated by the remote serial port
  133. ;
  134. .PROC   int_hndlr    ; *WARNING* - this routine MUST NOT be .REL
  135. .def    dataseg, ivecofst, int_segment, start_tdata, end_tdata, size_tdata
  136. .def    tdata, rdata, start_rdata, end_rdata, size_rdata
  137. .def    handleraddr
  138.         push    bp
  139.         push    ds
  140.         push    es
  141.         push    di
  142.         push    ax
  143.         push    bx
  144.         push    cx
  145.         push    dx
  146.  
  147. ; set up data segment
  148.         mov     ax,cs:dataseg
  149.         mov     ds,ax
  150.         mov     es,ax
  151.  
  152. ; find out where interrupt came from and jump to routine to handle it
  153.         mov     dx,iir
  154.         in      al,dx
  155.         cmp     al,rd
  156.         jz      rcv_chk          ; if it's from the receiver
  157.         cmp     al,wr
  158.         jz      tmit_chk          ; if it's from the transmitter
  159.         cmp     al,lstat
  160.         jz      lstat_int       ; interrupt becuase of line status
  161.         cmp     al,mstat
  162.         jz      mstat_int       ; interrupt because of modem status
  163.         jmp     int_end ; interrupt when no interrupt pending, go away
  164.  
  165. lstat_int:
  166.         mov     dx,lsr          ; clear interrupt
  167.         in      al,dx
  168.         jmp     repoll          ; see if any more interrupts
  169.  
  170. mstat_int:
  171.         mov     dx,msr          ; clear interrupt
  172.         in      al,dx
  173.         jmp     repoll          ; see if any more interrupts
  174.  
  175. tmit_chk:
  176.         mov     dx,lsr
  177.         in      al,dx
  178.         and     al,tcheck
  179.         jz      repoll          ; transmitter not yet ready, 
  180.                                 ;    so see if any more interrupts
  181.  
  182. .public SndSuspended
  183. goodtx: test    ss:SndSuspended, 1
  184.         jnz     $1
  185.         cmp     size_tdata,0    ; see if any more data to send
  186.         jne     have_data       ; if not equal then there is data to send
  187.  
  188. ; if no data to send, or host sent XOff, then reset tx interrupt and return
  189. $1      call    StopWriting
  190.         jmp     repoll
  191.  
  192. have_data:
  193. TSRReadyFlag    .equ    01000000T   ; the LSR bit indicating the Transmitter
  194.